//
//  AddCustomerCell1.m
//  WGFGlobalHouses
//
//  Created by waiguofang on 15/5/28.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//

#import "EditCustomerCell1.h"
#import "UIView+circular.h"
#import "StringTool.h"

#import "UserModal.h"

@interface EditCustomerCell1()<UITextFieldDelegate>

@property (weak, nonatomic) IBOutlet UIView *view1;
@property (weak, nonatomic) IBOutlet UIView *view2;


@property (weak, nonatomic) IBOutlet UITextField *phoneTextFiled;

@property (weak, nonatomic) IBOutlet UITextField *siteTextFiled;

@end


@implementation EditCustomerCell1

+(instancetype)cellWithTableView:(UITableView *)tableview
{
    static NSString *ID = @"editCustomerCell1";
    EditCustomerCell1 *cell = [tableview dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
       
        cell = [[[NSBundle mainBundle]loadNibNamed:@"EditCustomerCell1" owner:nil options:nil]lastObject];
        cell.nameTextField.delegate = cell;
        [cell.view1 viewToCircular];
        [cell.view2 viewToCircular];
    
    }
    return cell;
}

-(void)setModel:(CustomerModel *)model
{
    if (![StringTool isBlankString:model.consumerName]) {
        self.nameTextField.text = model.consumerName;
    }
    if (![StringTool isBlankString:model.consumerMobile]) {
        self.phoneTextFiled.text = model.consumerMobile;
    }
}
- (IBAction)clickLockSite:(id)sender {
    if (self.delegate && [self.delegate respondsToSelector:@selector(editCustomerCellClickLockSiteBtn)]) {
        [self.delegate editCustomerCellClickLockSiteBtn];
    }
}

+(CGFloat)getHeight;
{
    return 180;
}

- (void)textFieldDidEndEditing:(UITextField *)textField;
{
    if (![StringTool isBlankString:textField.text]) {
        [UserModal shareUserModel].editName = textField.text;
    }
    else
    {
        [UserModal shareUserModel].editName = self.nameTextField.text;
    }
}


- (BOOL)textFieldShouldReturn:(UITextField *)textField;
{
    [textField resignFirstResponder];
    return YES;
}
@end
